package com.example.collection

import com.example.man.Man

/**
 * 泛型的使用
 * @author 36466
 *
 */
class GenericDemo {
	
	static void main(String[] args) {
		// Creating a generic List collection
		ListType<String> lststr = new ListType<>();
		lststr.set("First String");
		println(lststr.get());
		  
		ListType<Integer> lstint = new ListType<>();
		lstint.set(1);
		println(lstint.get());
		
		ListType<Man> lstman = new ListType<>();
		Man man = new Man(1002,"zhangwei","001");
		lstman.set(man);
		println(lstman.get().name)
	 }
}

/*public class ListType<T> {
	private T localt;
	 
	public T get() {
	   return this.localt;
	}
	 
	public void set(T plocal) {
	   this.localt = plocal;
	}
}*/

public class ListType<T>{
	
	private T localt;
	public T get() {
		return this.localt;
	}
	public void set(T local) {
		this.localt = local	;
	}
}